﻿using System;
using System.Data;
using CoreLab.Oracle; //using Devart.Data.Oracle; //using Oracle.DataAccess.Client;
using System.Collections.Generic;

using LMD.Constant;
using LMD.Lib.DataClass;
using LMD.Lib.Oracle;

namespace DBQuery
{
    /// <summary>
    /// Summary description for CARSpocTable
    /// </summary>
    public static class CARSpocTable
    {
        public static void ChangeCARByCompany(int iCompanyId, String sxCarId)
        {
            DBLib dbl = new DBLib();
            ChangeCARByCompany(dbl, iCompanyId, sxCarId);
        }
        public static void ChangeCARByCompany(DBLib dbl, int iCompanyId, String sxCarId)
        {
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "out_new_id";
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Output;
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_COMPANY_ID";
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Input;
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;
            lsParams[lsParams.Count - 1].Value = iCompanyId;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NEW_CAR_EMPLOYEE_NO";
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Input;
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = sxCarId;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_UPDATE_BY";
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Input;
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = ICPUser.ID;

            String sxQuery = "PR_CHANGE_COMPANY_CAR";

            int i = dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());
        }
        public static void ChangeCARByCAR(String sxOldCarId, String sxCarId)
        {
            DBLib dbl = new DBLib();
            List<OracleParameter> lsParams = new List<OracleParameter>();

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "out_changed_count";
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Output;
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.Number;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_OLD_CAR_EMPLOYEE_NO";
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Input;
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = sxOldCarId;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_NEW_CAR_EMPLOYEE_NO";
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Input;
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = sxCarId;

            lsParams.Add(new OracleParameter());
            lsParams[lsParams.Count - 1].ParameterName = "in_UPDATE_BY";
            lsParams[lsParams.Count - 1].Direction = ParameterDirection.Input;
            lsParams[lsParams.Count - 1].OracleDbType = OracleDbType.VarChar;
            lsParams[lsParams.Count - 1].Value = ICPUser.ID;

            String sxQuery = "PR_SWITCH_CAR";

            int i = dbl.ExecuteProcedure(sxQuery, lsParams.ToArray());
            
        }
    }
}